package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Mylog;
import cn.wolfcode.mapper.MylogMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.IMylogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MylogServiceImpl implements IMylogService {

    @Autowired
    private MylogMapper mylogMapper;


    @Override
    public void save(Mylog mylog) {
        mylogMapper.insert(mylog);
    }

    @Override
    public void delete(Long id) {
        mylogMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Mylog mylog) {
        mylogMapper.updateByPrimaryKey(mylog);
    }

    @Override
    public Mylog get(Long id) {
        return mylogMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Mylog> listAll() {
        return mylogMapper.selectAll();
    }

    @Override
    public PageInfo<Mylog> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<Mylog> mylogs = mylogMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<Mylog>(mylogs);
    }
}
